﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DeliveryWayEdit.aspx.cs"
    Inherits="CNVP.JShop.Web.Admin.DeliveryWayEdit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <meta content="IE=7" http-equiv="X-UA-Compatible" />
    <link href="CSS/Global.css" rel="stylesheet" type="text/css" />
    <link href="CSS/Edit.css" rel="stylesheet" type="text/css" />
    <script src="../Scripts/jquery.js" type="text/javascript"></script>
    <script type="text/javascript" src="../Scripts/Common.js"></script>
</head>
<body onload="cb('_Kuaidi');cb('_EMS');cb('_Pingyou')">
    <form id="form1" runat="server">
    <div class="Content">
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="cell">
            <tr>
                <td class="cell_group">
                    <img src="Images/ListIconTitle.jpg" alt="" />&nbsp;您的位置：<a href="DeliveryWayList.aspx">配送管理</a><asp:Label
                        ID="lbTitle" runat="server"></asp:Label>
                </td>
            </tr>
        </table>
        <table border="0" cellpadding="0" cellspacing="0" class="division">
            <tr>
                <th>
                    模板名称:
                </th>
                <td>
                    <asp:TextBox ID="txtColumnName" runat="server" MaxLength="50" />
                </td>
            </tr>
            <tr>
                <th>
                    快递图片:
                </th>
                <td>
                    <asp:FileUpload ID="fileUp" runat="server" />
                    <br />
                    <asp:Image ID="imgPic" runat="server" Visible="false" Width="400" />
                    <asp:TextBox ID="txtPicOldName" runat="server" CssClass="Display"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <th>
                    是否显示:
                </th>
                <td>
                    <asp:RadioButtonList ID="rblIsShow" runat="server" RepeatDirection="Horizontal" Width="100px"
                        CssClass="RadioButtonListTable">
                        <asp:ListItem Selected="True" Value="1">是</asp:ListItem>
                        <asp:ListItem Value="0">否</asp:ListItem>
                    </asp:RadioButtonList>
                </td>
            </tr>
            <tr>
                <th>
                    排&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;序:
                </th>
                <td>
                    <asp:TextBox ID="txtOrderID" runat="server" />
                </td>
            </tr>
            <tr>
                <th>
                    备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注:
                </th>
                <td>
                    <asp:TextBox ID="txtText" runat="server" TextMode="MultiLine" CssClass="OrderText"  OnClick="clickText('#txtText')" OnBlur="blurText('#txtText')"></asp:TextBox>
                </td>
            </tr>
        </table>
        <!--Begin 快递-->
        <p>
            快递
            <input id="cb_Kuaidi" type="checkbox" name="cb_Kuaidi" onclick="cb('_Kuaidi')" <%=_ck %> /></p>
        <div id="div_Kuaidi" style="display: none;">
            <table border="0" cellpadding="0" cellspacing="0" class="division">
                <tr>
                    <th>
                        默认运费:
                    </th>
                    <td>
                        <input type="text" name="FirstPiece_Kuaidi" value="<%=_FirstPiece %>" />件内,
                    </td>
                    <td>
                        <input type="text" name="FirstFreight_Kuaidi" value="<%=_FirstFreight %>"  />元,
                    </td>
                    <th>
                        每增加:
                    </th>
                    <td>
                        <input type="text" name="AddPiece_Kuaidi" value="<%=_AddPiece %>"  />件,
                    </td>
                    <th>
                        增加运费:
                    </th>
                    <td>
                        <input type="text" name="AddFreight_Kuaidi" value="<%=_AddFreight %>" />元
                        <input id="ProvinceArrayName_kuaidi" name="ProvinceArrayName_kuaidi" type="hidden" />
                        <input id="ProvinceArrayCode_kuaidi" name="ProvinceArrayCode_kuaidi" type="hidden" />
                        <input id="CKIsDefault_kuaidi" name="CKIsDefault_kuaidi" type="checkbox" checked="checked"
                            value="1" class ="Display" />
                    </td>
                </tr>
            </table>
            <table id="tableEdit_Kuaidi" border="0" cellpadding="0" cellspacing="0" class="division">
                <tr>
                    <td colspan="7">
                        <input id="BtAdd_Kuaidi" type="button" value="为指定地区城市设置运费" onclick="BtAdd('_Kuaidi')" />&nbsp;<input
                            id="BtDel_Kuaidi" type="button" value="删除行" onclick="BtDel('_Kuaidi')" />
                    </td>
                </tr>
                <tr>
                    <td class="CheckBoxEdit">
                    </td>
                    <td class="CheckBoxEdit">
                        <input id="CKA_Kuaidi" name="CKA_Kuaidi" type="checkbox" onclick="CKASelect('_Kuaidi')" />
                    </td>
                    <td>
                        运送到
                    </td>
                    <td>
                        首件(件)
                    </td>
                    <td>
                        首费(元)
                    </td>
                    <td>
                        续件(件)
                    </td>
                    <td>
                        续费(元)
                    </td>
                </tr>
                <asp:Literal ID="Liter_kuaidi" runat="server"></asp:Literal>
            </table>
        </div>
        <!--End 快递-->
        <!--Begin EMS-->
        <p>
            EMS
            <input id="cb_EMS" type="checkbox" name="cb_EMS" onclick="cb('_EMS')" <%=_ck_EMS %>  /></p>
        <div id="div_EMS" style="display: none;" >
            <table border="0" cellpadding="0" cellspacing="0" class="division">
                <tr>
                    <th>
                        默认运费:
                    </th>
                    <td>
                        <input type="text" name="FirstPiece_EMS" value="<%=_FirstPiece_EMS %>" />件内,
                    </td>
                    <td>
                        <input type="text" name="FirstFreight_EMS" value="<%=_FirstFreight_EMS %>" />元,
                    </td>
                    <th>
                        每增加:
                    </th>
                    <td>
                        <input type="text" name="AddPiece_EMS"  value="<%=_AddPiece_EMS %>" />件,
                    </td>
                    <th>
                        增加运费:
                    </th>
                    <td>
                        <input type="text" name="AddFreight_EMS"  value="<%=_AddFreight_EMS %>" />元
                        <input id="ProvinceArrayName_EMS" name="ProvinceArrayName_EMS" type="hidden"  />
                        <input id="ProvinceArrayCode_EMS" name="ProvinceArrayCode_EMS" type="hidden"  />
                        <input id="CKIsDefault_EMS" name="CKIsDefault_EMS" type="checkbox" checked="checked"
                            value="1" class ="Display" />
                    </td>
                </tr>
            </table>
            <table id="tableEdit_EMS" border="0" cellpadding="0" cellspacing="0" class="division">
                <tr>
                    <td colspan="7">
                        <input id="BtAdd_EMS" type="button" value="为指定地区城市设置运费" onclick="BtAdd('_EMS')" />&nbsp;<input
                            id="BtDel_EMS" type="button" value="删除行" onclick="BtDel('_EMS')" />
                    </td>
                </tr>
                <tr>
                    <td class="CheckBoxEdit">
                    </td>
                    <td class="CheckBoxEdit">
                        <input id="CKA_EMS" name="CKA_EMS" type="checkbox" onclick="CKASelect('_EMS')" />
                    </td>
                    <td>
                        运送到
                    </td>
                    <td>
                        首件(件)
                    </td>
                    <td>
                        首费(元)
                    </td>
                    <td>
                        续件(件)
                    </td>
                    <td>
                        续费(元)
                    </td>
                </tr>
                <asp:Literal ID="Liter_EMS" runat="server"></asp:Literal>
            </table>
        </div>
        <!--End EMS-->
        <!--Begin 平邮-->
        <p>
            平邮
            <input id="cb_Pingyou" type="checkbox" name="cb_Pingyou" onclick="cb('_Pingyou')" <%=_ck_Pingyou %>  /></p>
        <div id="div_Pingyou" style="display: none;" >
            <table border="0" cellpadding="0" cellspacing="0" class="division">
                <tr>
                    <th>
                        默认运费:
                    </th>
                    <td>
                        <input type="text" name="FirstPiece_Pingyou" value="<%=_FirstPiece_Pingyou %>" />件内,
                    </td>
                    <td>
                        <input type="text" name="FirstFreight_Pingyou" value="<%=_FirstFreight_Pingyou %>" />元,
                    </td>
                    <th>
                        每增加:
                    </th>
                    <td>
                        <input type="text" name="AddPiece_Pingyou"  value="<%=_AddPiece_Pingyou %>" />件,
                    </td>
                    <th>
                        增加运费:
                    </th>
                    <td>
                        <input type="text" name="AddFreight_Pingyou"  value="<%=_AddFreight_Pingyou %>" />元
                        <input id="ProvinceArrayName_Pingyou" name="ProvinceArrayName_Pingyou" type="hidden"  />
                        <input id="ProvinceArrayCode_Pingyou" name="ProvinceArrayCode_Pingyou" type="hidden"  />
                        <input id="CKIsDefault_Pingyou" name="CKIsDefault_Pingyou" type="checkbox" checked="checked"
                            value="1" class ="Display" />
                    </td>
                </tr>
            </table>
            <table id="tableEdit_Pingyou" border="0" cellpadding="0" cellspacing="0" class="division">
                <tr>
                    <td colspan="7">
                        <input id="BtAdd_Pingyou" type="button" value="为指定地区城市设置运费" onclick="BtAdd('_Pingyou')" />&nbsp;<input
                            id="BtDel_Pingyou" type="button" value="删除行" onclick="BtDel('_Pingyou')" />
                    </td>
                </tr>
                <tr>
                    <td class="CheckBoxEdit">
                    </td>
                    <td class="CheckBoxEdit">
                        <input id="CKA_Pingyou" name="CKA_Pingyou" type="checkbox" onclick="CKASelect('_Pingyou')" />
                    </td>
                    <td>
                        运送到
                    </td>
                    <td>
                        首件(件)
                    </td>
                    <td>
                        首费(元)
                    </td>
                    <td>
                        续件(件)
                    </td>
                    <td>
                        续费(元)
                    </td>
                </tr>
                <asp:Literal ID="Liter_Pingyou" runat="server"></asp:Literal>
            </table>
        </div>
        <!--End 平邮-->
        <script type="text/javascript">
            function selectAll(RangeName_Str) {
                var RangeNameValue = document.getElementById("J_Group_" + RangeName_Str + "");
                var RangeName = RangeNameValue.value.split(",");
                for (var i = 0; i < RangeName.length; i++) {
                    //alert(RangeName[i]);
                    if (RangeNameValue.checked == true) {
                        document.getElementById("J_Province_" + RangeName[i] + "").checked = true;
                    }
                    else {
                        document.getElementById("J_Province_" + RangeName[i] + "").checked = false;
                    }
                }
            }
            function cb(DeliveryType) {
                var cbDeliveryType = document.getElementById("cb" + DeliveryType + "");
                if (cbDeliveryType.checked == true) {
                    $("#div" + DeliveryType + "").css("display", "");
                }
                else {
                    $("#div" + DeliveryType + "").css("display", "none");
                }
            }
            function BtAdd(DeliveryType) {
                var $table = $("#tableEdit" + DeliveryType + " tr");
                var len = $table.length - 1 + "add";
                var j = $table.length - 1;
                //alert(len);
                var AddTr = "";
                AddTr += "<tr>";
                AddTr += "	<td class=\"CheckBoxEdit\" >" + j + "</td>";
                AddTr += "	<td class=\"CheckBoxEdit\">";
                AddTr += "		<input id=\"CK" + DeliveryType + "\" name=\"CK" + DeliveryType + "\" type=\"checkbox\"/><input id=\"CKIsDefault" + DeliveryType + "\" name=\"CKIsDefault" + DeliveryType + "\" type=\"checkbox\" checked=\"checked\" value=\"0\" class =\"Display\"/></td>";
                AddTr += "	<td>";
                AddTr += "		<span id=\"ProvinceArray" + DeliveryType + "" + len + "\" >未添加地区</span>";
                AddTr += "      <input id=\"ProvinceArrayName" + DeliveryType + "" + len + "\" name=\"ProvinceArrayName" + DeliveryType + "\" type=\"hidden\" />";
                AddTr += "		<input id=\"ProvinceArrayCode" + DeliveryType + "" + len + "\" name=\"ProvinceArrayCode" + DeliveryType + "\" type=\"hidden\" />";
                AddTr += "		<a id=\"ProvinceEidt" + DeliveryType + "" + len + "\" onclick=\"show_pl('" + DeliveryType + "','ProvinceArray" + DeliveryType + "" + len + "','ProvinceArrayName" + DeliveryType + "" + len + "','ProvinceArrayCode" + DeliveryType + "" + len + "')\"  href=\"javascript:void(0)\" target=\"_self\">编辑</a></td>";
                AddTr += "	<td >";
                AddTr += "		<input id=\"FirstPiece" + DeliveryType + "" + len + "\" type=\"text\" name=\"FirstPiece" + DeliveryType + "\" maxlength=\"20\" value=\"1\"  /></td>";
                AddTr += "	<td>";
                AddTr += "		<input id=\"FirstFreight" + DeliveryType + "" + len + "\" type=\"text\" name=\"FirstFreight" + DeliveryType + "\" maxlength=\"20\" /></td>";
                AddTr += "	<td >";
                AddTr += "		<input id=\"AddPiece" + DeliveryType + "" + len + "\" type=\"text\" name=\"AddPiece" + DeliveryType + "\" maxlength=\"50\" maxlength=\"20\" value=\"1\"  /></td>";
                AddTr += "	<td>";
                AddTr += "		<input id=\"AddFreight" + DeliveryType + "" + len + "\" type=\"text\" name=\"AddFreight" + DeliveryType + "\" maxlength=\"20\" /></td>";
                AddTr += "</tr>";
                $("#tableEdit" + DeliveryType + "").append(AddTr);
            }
            function BtDel(DeliveryType) {
                if (ifEditCheckValue(DeliveryType)) {
                    if (confirm("你确定要删除！")) {
                        $("#tableEdit" + DeliveryType + " tr:gt(1)").each(function () {
                            if ($(this).find("#CK" + DeliveryType + "").get(0).checked == true) {
                                $(this).remove();
                            }
                        });
                    }
                }
                else {
                    alert('请选择记录！');
                    return false;
                }
            }
            function CKASelect(DeliveryType) {
                $("#tableEdit" + DeliveryType + " tr:gt(1)").each(function () {
                    $(this).find("#CK" + DeliveryType + "").get(0).checked = $("#CKA" + DeliveryType + "").get(0).checked;
                });
            }
            function show_pl(DeliveryType, ProvinceArray, ProvinceArrayName,ProvinceArrayCode) {
                var ProvinceArrayCodeValue = $("#" + ProvinceArrayCode + "").val();
                comment_login.style.display = "block";
                document.getElementById("comment_login").style.top = (document.documentElement.scrollTop + (document.documentElement.clientHeight - document.getElementById("comment_login").offsetHeight) / 2) + "px";
                document.getElementById("comment_login").style.left = (document.documentElement.scrollLeft + (document.documentElement.clientWidth - document.getElementById("comment_login").offsetWidth) / 2) + "px";
                var result = GetAjaxResponse("/Admin/CommonWindows/ProvinceArray.aspx?ProvinceArray=" + ProvinceArray + "&ProvinceArrayName=" + ProvinceArrayName + "&ProvinceArrayCode=" + ProvinceArrayCode + "&ProvinceArrayCodeValue=" + ProvinceArrayCodeValue + "");
                if (result != null) {
                    $("#comment_login").html(result);
                }
                var ArrayCode = "";
                var inputS = $("input[name='ProvinceArrayCode" + DeliveryType + "']");
                for (var i = 0; i < inputS.length; i++) {
                    if ($(inputS[i]).attr("id") != ProvinceArrayCode) {
                        ArrayCode += $(inputS[i]).attr("value");
                    }
                }
                if (ArrayCode != "") {
                    var arrCode = ArrayCode.split("|");
                    for (var k = 0; k < arrCode.length; k++) {
                        if ($("#J_Province_" + arrCode[k] + "").val() == arrCode[k]) {
                            $("#J_Province_" + arrCode[k] + "").attr("disabled", "disabled");
                        }
                    }
                }
            }
            function ProvinceArrayUp(ProvinceArray, ProvinceArrayName, ProvinceArrayCode) {
                var totalArray = "";
                var totalArrayCode = "";
                $("input[name='J_Province']").each(
                    function () {
                        if (this.checked == true) {
                            totalArrayCode += $(this).val() + "|";
                            totalArray += $("#Province_" + $(this).val() + "").html() + "|";
                        }
                    }
                );
                var totalArray = totalArray.substring(0, totalArray.length - 1);
                $("#" + ProvinceArray + "").html(totalArray);
                $("#" + ProvinceArrayCode + "").val(totalArrayCode);
                $("#" + ProvinceArrayName + "").val(totalArray);
                close_pl();
            }
            function close_pl() {
                comment_login.style.display = "none";
            }
        </script>
        <div id="comment_login" class="ks-contentbox">
        </div>
    <div class="EditBtn">
        <asp:Button ID="btUp" runat="server" Text="提交" OnClick="btUp_Click" />
        <input type="button" value="取消" onclick="javascript:history.go(-1)" />
    </div>
    </div>
    </form>
    <script type="text/javascript">
        $(function () {
            $("#btUp").click(function () {
                var $txtColumnName = $("#txtColumnName");
                var $txtDepth = $("#txtDepth");
                var $txtOrderID = $("#txtOrderID");
                if ($txtColumnName.val() == "") {
                    alert("请输入模板名称！");
                    $txtColumnName.focus();
                    return false;
                }
                if ($txtOrderID.val() != "") {
                    if (!IsInteger($txtOrderID.val())) {
                        alert("排序格式不正确！");
                        $txtOrderID.focus();
                        return false;
                    }
                }
                if (!ProvinceArrayCodeFlag("kuaidi")) {
                    alert("快递请选择指定地区！");
                    return false;
                }
                if (!ProvinceArrayCodeFlag("EMS")) {
                    alert("EMS请选择指定地区！");
                    return false;
                }
                if (!ProvinceArrayCodeFlag("Pingyou")) {
                    alert("平邮请选择指定地区！");
                    return false;
                }
                return true;
            });

        })
        function ProvinceArrayCodeFlag(type) {
            var codeType = document.getElementsByName("ProvinceArrayCode_" + type + "");
            for (var k = 1; k < codeType.length; k++) {
                if (codeType[k].value == "") {
                    return false;
                }
            }
            return true;
        }
    </script>
</body>
</html>
